import { ethers } from "hardhat";
import {getConsumer} from "../../scripts/chainLink/VRFCoordinatorV2Consumer";
import { expect } from "chai";
import { Contract } from "ethers";
describe("test Consumer",()=>{
    let VRFConsumerContract:Contract;
    let mockContract:Contract;
        //不同it之间执行顺序不确定？ 
    it('check if we can request random num',async()=>{
        // 请求随机数
        await VRFConsumerContract.requestRandomWords();   
        let requestId= await VRFConsumerContract.s_requestId();
        console.log('requestId为'+requestId);
      // 触发随机数填充
       await mockContract.fulfillRandomWords(requestId,await VRFConsumerContract.getAddress()) ;
        console.log(await VRFConsumerContract.s_randomWords(0));
    })
    
    beforeEach(async()=>{
        // 部署合约
        let consumer;
        consumer=await getConsumer()
        VRFConsumerContract=await consumer.VRFConsumerContract
        mockContract=await consumer.mockContract
    })

})